struct ListNode* getIntersectionNode(struct ListNode* head1, struct ListNode* head2)
{
    struct ListNode* cur1 = head1, * cur2 = head2;
    int len1 = 1, len2 = 1;
    while (cur1)
    {
        cur1->next;
        len1++;
    }
    while (cur2)
    {
        cur2->next;
        len2++;
    }
    if (cur1 != cur2)
        return NULL;
    int gap = abs(len2 - len1);
    struct ListNode* longnode = head1;
    struct ListNode* shortnode = head2;
    if (len2 > len1)
    {
        longnode = head2;
        shortnode = head1;
    }
    while (gap)
    {
        longnode = longnode->next;
        gap--;
    }
    while (longnode && shortnode)
    {
        if (longnode != shortnode)
            longnode = longnode->next;
        shortnode = shortnode->next;
    }
    return longnode;
}